package com.itheima.health.utils.poi;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.*;

public class MainPoi {

   public static void main(String[] args) throws Exception {
//           读取excel
//        readExcel();
//       创建文件
        creatExcel();

            }


          private static void creatExcel() throws Exception {
//       生成文件
             String outputfilepath ="/Users/yhl/Downloads/yhl.xlsx";
              XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
              XSSFSheet sheet = xssfWorkbook.createSheet("传智健康");
              XSSFRow row = sheet.createRow(0);
              row.createCell(0).setCellValue("检查项");
              row.createCell(0).setCellValue("检查组");
              row.createCell(0).setCellValue("套餐");
              row.createCell(0).setCellValue("预约管理");
              XSSFRow row1 = sheet.createRow(1);
              row1.createCell(0).setCellValue("身高");
              row1.createCell(0).setCellValue("一般检查");
              row1.createCell(0).setCellValue("入职无忧");
              row1.createCell(0).setCellValue("嘿嘿嘿");


              xssfWorkbook.write(new FileOutputStream(outputfilepath));

          }
           private static  void readExcel() throws Exception {
//        输入流 HSSF XSSF
                InputStream in =new FileInputStream("/Users/yhl/Downloads/hello.xlsx");
                XSSFWorkbook xssfWorkbook = new XSSFWorkbook(in);
                XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
                for (Row row : sheet) {
                    for (Cell cell : row) {
                        System.out.println(cell.getStringCellValue()+"\t");
                    }
                    System.out.println();
                }


            }

}

